package com.jzx.provider.common.utils;

import java.util.Random;

/**
 * @author daihuihui
 * @date 2019/2/7
 * @des 随机生成验证码
 */
public class CodeUtil {
    private final static String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

    private final static String num = "0123456789";

    /**
     * 生成盐
     * @return
     */
    public static String salt() {
        String uuid = new String();
        for (int i = 0; i < 4; i++) {
            char ch = str.charAt(new Random().nextInt(str.length()));
            uuid += ch;
        }
        return uuid;
    }

    /**
     * 手机验证码生成
     * @return
     */
    public static String mobileCode() {
        String uuid = new String();
        for (int i = 0; i < 4; i++) {
            char nu = num.charAt(new Random().nextInt(num.length()));
            uuid += nu;
        }
        return uuid;
    }
}
